package site.lianwu.mybatis.plus.query.model;

import site.lianwu.mybatis.plus.query.Query;
import site.lianwu.mybatis.plus.query.processor.GeneralQueryFieldProcessor;

import java.lang.reflect.Field;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 常规查询字段，封装{@link Query}所声明的{@code Field}信息
 *
 * @author LianWu
 * @see Query
 * @see GeneralQueryFieldProcessor
 */
public class GeneralQueryField extends QueryField {

    /**
     * 预备的查询语句列表，提取{@link Query}的结果封装
     */
    private final List<PreparedQueryStatement> preparedQueryStatements;

    public GeneralQueryField(Field field, List<PreparedQueryStatement> preparedQueryStatements) {
        super(field, preparedQueryStatements.stream().map(PreparedQueryStatement::getGroup).collect(Collectors.toSet()));
        this.preparedQueryStatements = preparedQueryStatements;
    }

    public List<PreparedQueryStatement> getPreparedQueryStatements() {
        return preparedQueryStatements;
    }

}
